<template>
  <div class="profile-page">
    <div class="page-header">
      <div class="container">
        <h1 class="page-title">个人中心</h1>
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/portal' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>患者服务</el-breadcrumb-item>
          <el-breadcrumb-item>个人中心</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
    </div>
    
    <div class="container main-content">
      <el-row :gutter="20" v-loading="loading">
        <!-- 左侧个人信息卡片 -->
        <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="6">
          <div class="user-card">
            <div class="user-avatar">
              <el-avatar :size="100" :src="userAvatar">
                {{ userStore.name?.charAt(0) || userStore.username?.charAt(0) || '患' }}
              </el-avatar>
            </div>
            <h2 class="user-name">{{ patientInfo.name || userStore.name || userStore.username }}</h2>
            <p class="user-role">患者</p>
            <div class="user-stats">
              <div class="stat-item">
                <div class="stat-value">{{ patientStats.appointments || 0 }}</div>
                <div class="stat-label">预约数</div>
              </div>
              <div class="stat-item">
                <div class="stat-value">{{ patientStats.visits || 0 }}</div>
                <div class="stat-label">就诊数</div>
              </div>
              <div class="stat-item">
                <div class="stat-value">{{ patientStats.reports || 0 }}</div>
                <div class="stat-label">报告数</div>
              </div>
            </div>
            <div class="patient-tags" v-if="patientInfo.tags && patientInfo.tags.length">
              <el-tag v-for="tag in patientInfo.tags" :key="tag" :type="getTagType(tag)" size="small" class="tag-item">
                {{ tag }}
              </el-tag>
            </div>
          </div>
        </el-col>
        
        <!-- 右侧信息和设置 -->
        <el-col :xs="24" :sm="24" :md="16" :lg="18" :xl="18">
          <el-tabs>
            <!-- 个人资料标签页 -->
            <el-tab-pane label="个人资料">
              <el-card class="info-card">
                <template #header>
                  <div class="card-header">
                    <span>基本信息</span>
                    <el-button type="primary" @click="editMode = !editMode">
                      {{ editMode ? '取消编辑' : '编辑信息' }}
                    </el-button>
                  </div>
                </template>
                
                <el-form 
                  :model="patientForm" 
                  :rules="patientRules" 
                  ref="patientFormRef"
                  label-width="120px"
                  :disabled="!editMode"
                >
                  <el-form-item label="患者ID" prop="patientId">
                    <el-input v-model="patientForm.patientId" disabled></el-input>
                  </el-form-item>
                  <el-form-item label="姓名" prop="name">
                    <el-input v-model="patientForm.name"></el-input>
                  </el-form-item>
                  <el-form-item label="性别" prop="gender">
                    <el-select v-model="patientForm.gender" placeholder="请选择">
                      <el-option label="男" value="男"></el-option>
                      <el-option label="女" value="女"></el-option>
                      <el-option label="其他" value="其他"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="身份证号" prop="idNumber">
                    <el-input v-model="patientForm.idNumber"></el-input>
                  </el-form-item>
                  <el-form-item label="出生日期" prop="birthDate">
                    <el-date-picker 
                      v-model="patientForm.birthDate" 
                      type="date" 
                      placeholder="选择日期"
                      format="YYYY-MM-DD"
                      value-format="YYYY-MM-DD"
                    ></el-date-picker>
                  </el-form-item>
                  <el-form-item label="联系电话" prop="phone">
                    <el-input v-model="patientForm.contactInfo.phone"></el-input>
                  </el-form-item>
                  <el-form-item label="联系地址" prop="address">
                    <el-input v-model="patientForm.contactInfo.address"></el-input>
                  </el-form-item>
                  <el-form-item label="电子邮箱" prop="email">
                    <el-input v-model="userForm.email"></el-input>
                  </el-form-item>
                  <el-form-item v-if="editMode">
                    <el-button type="primary" @click="updatePatientInfo">保存信息</el-button>
                    <el-button @click="resetForm">重置</el-button>
                  </el-form-item>
                </el-form>
              </el-card>
            </el-tab-pane>
            
            <!-- 健康档案标签页 (合并了医疗信息和保险信息) -->
            <el-tab-pane label="健康档案">
              <!-- 医疗信息卡片 -->
              <el-card class="info-card">
                <template #header>
                  <div class="card-header">
                    <span>医疗信息</span>
                    <el-button type="primary" @click="editMode = !editMode">
                      {{ editMode ? '取消编辑' : '编辑信息' }}
                    </el-button>
                  </div>
                </template>
                
                <el-form 
                  :model="medicalForm" 
                  ref="medicalFormRef"
                  label-width="120px"
                  :disabled="!editMode"
                >
                  <el-form-item label="血型" prop="bloodType">
                    <el-select v-model="medicalForm.bloodType" placeholder="请选择">
                      <el-option label="A型" value="A"></el-option>
                      <el-option label="B型" value="B"></el-option>
                      <el-option label="AB型" value="AB"></el-option>
                      <el-option label="O型" value="O"></el-option>
                      <el-option label="未知" value="未知"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="过敏源" prop="allergies">
                    <el-select 
                      v-model="medicalForm.allergies" 
                      multiple 
                      filterable 
                      allow-create 
                      default-first-option 
                      placeholder="请输入过敏源"
                    >
                      <el-option label="青霉素" value="青霉素"></el-option>
                      <el-option label="磺胺类药物" value="磺胺类药物"></el-option>
                      <el-option label="海鲜" value="海鲜"></el-option>
                      <el-option label="花粉" value="花粉"></el-option>
                      <el-option label="尘螨" value="尘螨"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="慢性病" prop="chronicDiseases">
                    <el-select 
                      v-model="medicalForm.chronicDiseases" 
                      multiple 
                      filterable 
                      allow-create 
                      default-first-option 
                      placeholder="请输入慢性病"
                    >
                      <el-option label="高血压" value="高血压"></el-option>
                      <el-option label="糖尿病" value="糖尿病"></el-option>
                      <el-option label="冠心病" value="冠心病"></el-option>
                      <el-option label="慢性支气管炎" value="慢性支气管炎"></el-option>
                      <el-option label="慢性胃炎" value="慢性胃炎"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item v-if="editMode">
                    <el-button type="primary" @click="updatePatientInfo">保存信息</el-button>
                  </el-form-item>
                </el-form>
              </el-card>
              
              <!-- 保险信息卡片 -->
              <el-card class="info-card mt-20" v-if="patientInfo.insuranceInfo">
                <template #header>
                  <div class="card-header">
                    <span>保险信息</span>
                  </div>
                </template>
                
                <el-form 
                  :model="insuranceForm" 
                  ref="insuranceFormRef"
                  label-width="120px"
                  :disabled="!editMode"
                >
                  <el-form-item label="保险提供商" prop="provider">
                    <el-input v-model="insuranceForm.provider"></el-input>
                  </el-form-item>
                  <el-form-item label="保单号" prop="policyNumber">
                    <el-input v-model="insuranceForm.policyNumber"></el-input>
                  </el-form-item>
                  <el-form-item label="到期日期" prop="expiryDate">
                    <el-date-picker 
                      v-model="insuranceForm.expiryDate" 
                      type="date" 
                      placeholder="选择日期"
                      format="YYYY-MM-DD"
                      value-format="YYYY-MM-DD"
                    ></el-date-picker>
                  </el-form-item>
                  <el-form-item v-if="editMode">
                    <el-button type="primary" @click="updatePatientInfo">保存信息</el-button>
                    <el-button @click="resetForm">重置</el-button>
                  </el-form-item>
                </el-form>
              </el-card>
            </el-tab-pane>
            
            <!-- 安全设置标签页 -->
            <el-tab-pane label="安全设置">
              <el-card class="info-card">
                <template #header>
                  <div class="card-header">
                    <span>修改密码</span>
                  </div>
                </template>
                
                <el-form 
                  :model="passwordForm" 
                  :rules="passwordRules" 
                  ref="passwordFormRef"
                  label-width="120px"
                >
                  <el-form-item label="当前密码" prop="oldPassword">
                    <el-input 
                      v-model="passwordForm.oldPassword" 
                      type="password" 
                      show-password
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="新密码" prop="newPassword">
                    <el-input 
                      v-model="passwordForm.newPassword" 
                      type="password" 
                      show-password
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="确认新密码" prop="confirmPassword">
                    <el-input 
                      v-model="passwordForm.confirmPassword" 
                      type="password" 
                      show-password
                    ></el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="changePassword">修改密码</el-button>
                    <el-button @click="resetPasswordForm">重置</el-button>
                  </el-form-item>
                </el-form>
              </el-card>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useUserStore } from '@/stores/user'
import { patientAPI, userAPI, authAPI } from '@/utils/api'

const router = useRouter()
const userStore = useUserStore()
const editMode = ref(false)
const loading = ref(false)
const patientFormRef = ref(null)
const medicalFormRef = ref(null)
const insuranceFormRef = ref(null)
const passwordFormRef = ref(null)

// 当前用户ID
const currentUserId = ref('')

// 患者信息
const patientInfo = reactive({
  id: '',
  patientId: '',
  name: '',
  gender: '其他',
  birthDate: '',
  idNumber: '',
  contactInfo: {
    phone: '',
    address: ''
  },
  medicalInfo: {
    bloodType: '',
    allergies: [],
    chronicDiseases: []
  },
  insuranceInfo: {
    provider: '',
    policyNumber: '',
    expiryDate: ''
  },
  tags: [],
  createdAt: '',
  updatedAt: '',
  registrationDate: '',
  activeStatus: true
})

// 用户信息
const userInfo = reactive({
  id: '',
  username: '',
  name: '',
  email: '',
  role: ''
})

// 用户头像
const userAvatar = computed(() => {
  return userStore.avatar || ''
})

// 统计数据
const patientStats = reactive({
  appointments: 3,
  visits: 5,
  reports: 2
})

// 患者表单数据
const patientForm = reactive({
  patientId: '',
  name: '',
  gender: '其他',
  idNumber: '',
  birthDate: '',
  contactInfo: {
    phone: '',
    address: ''
  }
})

// 用户表单数据 - 存储邮箱等用户信息
const userForm = reactive({
  email: ''
})

// 医疗表单数据
const medicalForm = reactive({
  bloodType: '',
  allergies: [],
  chronicDiseases: []
})

// 保险表单数据
const insuranceForm = reactive({
  provider: '',
  policyNumber: '',
  expiryDate: ''
})

// 密码表单数据
const passwordForm = reactive({
  oldPassword: '',
  newPassword: '',
  confirmPassword: ''
})

// 表单验证规则
const patientRules = {
  name: [
    { required: true, message: '请输入姓名', trigger: 'blur' },
    { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
  ],
  gender: [
    { required: true, message: '请选择性别', trigger: 'change' }
  ],
  idNumber: [
    { pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '请输入正确的身份证号码', trigger: 'blur' }
  ],
  'contactInfo.phone': [
    { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
  ]
}

const passwordRules = {
  oldPassword: [
    { required: true, message: '请输入当前密码', trigger: 'blur' },
    { min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
  ],
  newPassword: [
    { required: true, message: '请输入新密码', trigger: 'blur' },
    { min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
  ],
  confirmPassword: [
    { required: true, message: '请再次输入新密码', trigger: 'blur' },
    { 
      validator: (rule, value, callback) => {
        if (value !== passwordForm.newPassword) {
          callback(new Error('两次输入密码不一致'))
        } else {
          callback()
        }
      }, 
      trigger: 'blur' 
    }
  ]
}

// 检查用户是否已登录
onMounted(() => {
  if (!userStore.isLoggedIn) {
    ElMessage.warning('请先登录后再访问个人中心')
    router.push({
      path: '/portal/login',
      query: { redirect: '/portal/patient/profile' }
    })
    return
  }
  
  // 已登录，加载用户资料
  loadPatientProfile()
})

// 加载患者资料
const loadPatientProfile = async () => {
  loading.value = true
  try {
    // 先获取用户信息
    const userRes = await authAPI.getUserInfo()
    if (!userRes.success) {
      throw new Error(userRes.message || '获取用户信息失败')
    }
    
    // 检查响应结构
    console.log('用户信息API响应:', userRes)
    
    // 判断返回的数据结构
    let userData = null
    if (userRes.data.user) {
      userData = userRes.data.user
    } else if (userRes.data) {
      userData = userRes.data
    } else {
      throw new Error('获取用户信息失败: 无效的数据结构')
    }
    
    console.log('用户信息:', userData)
    
    // 检查用户角色
    if (userData.role !== 'patient') {
      ElMessage.warning('您不是患者角色，无法查看患者资料')
      return
    }
    
    // 保存当前用户ID和基本信息
    currentUserId.value = userData.id
    
    // 更新用户信息
    Object.assign(userInfo, {
      id: userData.id,
      username: userData.username,
      name: userData.name,
      email: userData.email,
      role: userData.role
    })
    
    // 填充用户表单
    userForm.email = userData.email || ''
    
    // 通过用户ID查找患者记录
    // 先尝试获取患者列表
    const patientsRes = await patientAPI.getPatients({ userId: userData.id })
    if (!patientsRes.success) {
      throw new Error(patientsRes.message || '获取患者信息失败')
    }
    
    // 从返回的患者列表中找到当前用户关联的患者
    const patients = patientsRes.data.patients
    let patientData = null
    
    if (patients && patients.length > 0) {
      // 找到与用户ID匹配的患者记录
      patientData = patients.find(p => p.userId === userData.id)
    }
    
    // 如果没有找到患者记录
    if (!patientData) {
      console.warn('未找到关联的患者记录，尝试直接使用用户ID查询')
      
      // 尝试直接使用用户ID查询单个患者
      try {
        const patientRes = await patientAPI.getPatient(userData.id)
        if (patientRes.success) {
          patientData = patientRes.data
        }
      } catch (err) {
        console.error('通过用户ID查询患者失败:', err)
      }
    }
    
    // 如果仍然没有找到患者记录
    if (!patientData) {
      ElMessage.error('未找到您的患者档案，请联系管理员')
      return
    }
    
    // 更新患者信息
    Object.assign(patientInfo, patientData)
    
    // 处理性别字段，确保符合后端需求
    if (patientInfo.gender === '未知') {
      patientInfo.gender = '其他'
    }
    
    // 填充表单数据
    patientForm.patientId = patientInfo.patientId || ''
    patientForm.name = patientInfo.name || ''
    patientForm.gender = patientInfo.gender || '其他'
    patientForm.idNumber = patientInfo.idNumber || ''
    
    // 处理出生日期格式
    if (patientInfo.birthDate) {
      if (typeof patientInfo.birthDate === 'string') {
        patientForm.birthDate = patientInfo.birthDate
      } else if (patientInfo.birthDate instanceof Date) {
        patientForm.birthDate = patientInfo.birthDate.toISOString().split('T')[0]
      } else {
        patientForm.birthDate = ''
      }
    } else {
      patientForm.birthDate = ''
    }
    
    // 确保联系信息对象存在
    if (!patientInfo.contactInfo) {
      patientInfo.contactInfo = { phone: '', address: '' }
    }
    
    patientForm.contactInfo.phone = patientInfo.contactInfo.phone || ''
    patientForm.contactInfo.address = patientInfo.contactInfo.address || ''
    
    // 确保医疗信息对象存在
    if (!patientInfo.medicalInfo) {
      patientInfo.medicalInfo = { bloodType: '', allergies: [], chronicDiseases: [] }
    }
    
    // 填充医疗信息
    medicalForm.bloodType = patientInfo.medicalInfo.bloodType || ''
    medicalForm.allergies = patientInfo.medicalInfo.allergies || []
    medicalForm.chronicDiseases = patientInfo.medicalInfo.chronicDiseases || []
    
    // 确保保险信息对象存在
    if (!patientInfo.insuranceInfo) {
      patientInfo.insuranceInfo = { provider: '', policyNumber: '', expiryDate: '' }
    }
    
    // 填充保险信息
    insuranceForm.provider = patientInfo.insuranceInfo.provider || ''
    insuranceForm.policyNumber = patientInfo.insuranceInfo.policyNumber || ''
    
    // 处理保险到期日期格式
    if (patientInfo.insuranceInfo.expiryDate) {
      if (typeof patientInfo.insuranceInfo.expiryDate === 'string') {
        insuranceForm.expiryDate = patientInfo.insuranceInfo.expiryDate
      } else if (patientInfo.insuranceInfo.expiryDate instanceof Date) {
        insuranceForm.expiryDate = patientInfo.insuranceInfo.expiryDate.toISOString().split('T')[0]
      } else {
        insuranceForm.expiryDate = ''
      }
    } else {
      insuranceForm.expiryDate = ''
    }
    
    console.log('患者资料加载成功:', patientInfo)
  } catch (error) {
    console.error('加载患者资料失败:', error)
    ElMessage.error('加载患者资料失败: ' + (error.message || '未知错误'))
  } finally {
    loading.value = false
  }
}

// 更新患者信息
const updatePatientInfo = async () => {
  try {
    // 先验证表单
    await patientFormRef.value.validate()
    
    // 检查邮箱是否发生变更
    const emailChanged = userForm.email !== userInfo.email
    
    // 准备更新患者数据，严格按照后端PatientUpdateSchema设计
    const patientUpdateData = {
      name: patientForm.name,
      gender: patientForm.gender === '未知' ? '其他' : patientForm.gender
    }
    
    // 处理联系信息，确保符合ContactInfoSchema
    if (patientForm.contactInfo) {
      patientUpdateData.contactInfo = {
        phone: patientForm.contactInfo.phone || ''
      }
      
      if (patientForm.contactInfo.address) {
        patientUpdateData.contactInfo.address = patientForm.contactInfo.address
      }
    }
    
    // 处理医疗信息，只传递有效字段
    if (medicalForm.bloodType || medicalForm.allergies.length > 0 || medicalForm.chronicDiseases.length > 0) {
      patientUpdateData.medicalInfo = {}
      
      if (medicalForm.bloodType) {
        patientUpdateData.medicalInfo.bloodType = medicalForm.bloodType
      }
      
      if (medicalForm.allergies.length > 0) {
        patientUpdateData.medicalInfo.allergies = medicalForm.allergies
      }
      
      if (medicalForm.chronicDiseases.length > 0) {
        patientUpdateData.medicalInfo.chronicDiseases = medicalForm.chronicDiseases
      }
    }
    
    // 只有当身份证号符合要求时才添加
    if (patientForm.idNumber && /^\d{17}[\dXx]$/.test(patientForm.idNumber)) {
      patientUpdateData.idNumber = patientForm.idNumber
    }
    
    // 处理出生日期 - 确保是YYYY-MM-DD格式字符串
    if (patientForm.birthDate) {
      // 如果是Date对象，转换为YYYY-MM-DD格式
      if (patientForm.birthDate instanceof Date) {
        const year = patientForm.birthDate.getFullYear()
        const month = String(patientForm.birthDate.getMonth() + 1).padStart(2, '0')
        const day = String(patientForm.birthDate.getDate()).padStart(2, '0')
        patientUpdateData.birthDate = `${year}-${month}-${day}`
      } 
      // 如果是字符串但包含时间部分，去除时间部分
      else if (typeof patientForm.birthDate === 'string' && patientForm.birthDate.includes('T')) {
        patientUpdateData.birthDate = patientForm.birthDate.split('T')[0]
      }
      // 其他情况直接使用
      else {
        patientUpdateData.birthDate = patientForm.birthDate
      }
    }
    
    // 处理保险信息
    if (insuranceForm.provider || insuranceForm.policyNumber || insuranceForm.expiryDate) {
      patientUpdateData.insuranceInfo = {}
      
      if (insuranceForm.provider) {
        patientUpdateData.insuranceInfo.provider = insuranceForm.provider
      }
      
      if (insuranceForm.policyNumber) {
        patientUpdateData.insuranceInfo.policyNumber = insuranceForm.policyNumber
      }
      
      // 处理保险到期日期 - 确保是YYYY-MM-DD格式
      if (insuranceForm.expiryDate) {
        // 如果是Date对象，转换为YYYY-MM-DD格式
        if (insuranceForm.expiryDate instanceof Date) {
          const year = insuranceForm.expiryDate.getFullYear()
          const month = String(insuranceForm.expiryDate.getMonth() + 1).padStart(2, '0')
          const day = String(insuranceForm.expiryDate.getDate()).padStart(2, '0')
          patientUpdateData.insuranceInfo.expiryDate = `${year}-${month}-${day}`
        } 
        // 如果是字符串但包含时间部分，去除时间部分
        else if (typeof insuranceForm.expiryDate === 'string' && insuranceForm.expiryDate.includes('T')) {
          patientUpdateData.insuranceInfo.expiryDate = insuranceForm.expiryDate.split('T')[0]
        }
        // 其他情况直接使用
        else {
          patientUpdateData.insuranceInfo.expiryDate = insuranceForm.expiryDate
        }
      }
    }
    
    console.log('更新患者数据:', patientUpdateData)
    
    // 更新患者信息
    const patientRes = await patientAPI.updatePatient(patientInfo.id, patientUpdateData)
    if (!patientRes.success) {
      throw new Error(patientRes.message || '更新患者信息失败')
    }
    
    // 如果邮箱发生变更，则更新用户信息
    if (emailChanged && currentUserId.value) {
      console.log('更新用户邮箱:', userForm.email)
      
      const userUpdateData = {
        email: userForm.email
      }
      
      const userRes = await userAPI.updateUser(currentUserId.value, userUpdateData)
      if (!userRes.success) {
        throw new Error(userRes.message || '更新邮箱失败')
      }
    }
    
    ElMessage.success('更新信息成功')
    editMode.value = false
    
    // 重新加载患者资料
    loadPatientProfile()
  } catch (error) {
    console.error('更新患者信息失败:', error)
    ElMessage.error('更新患者信息失败: ' + (error.message || '未知错误'))
  }
}

// 修改密码
const changePassword = async () => {
  try {
    // 先验证表单
    await passwordFormRef.value.validate()
    
    // 调用修改密码API
    const res = await authAPI.changePassword({
      oldPassword: passwordForm.oldPassword,
      newPassword: passwordForm.newPassword
    })
    
    if (!res.success) {
      throw new Error(res.message || '修改密码失败')
    }
    
    ElMessage.success('修改密码成功，请重新登录')
    
    // 重置密码表单
    resetPasswordForm()
    
    // 退出登录
    setTimeout(() => {
      userStore.logout()
      router.push('/portal/login')
    }, 1500)
  } catch (error) {
    console.error('修改密码失败:', error)
    ElMessage.error('修改密码失败: ' + (error.message || '未知错误'))
  }
}

// 重置表单
const resetForm = () => {
  loadPatientProfile()
}

// 重置密码表单
const resetPasswordForm = () => {
  passwordFormRef.value.resetFields()
}

// 获取标签类型
const getTagType = (tag) => {
  const tagMap = {
    'VIP': 'success',
    '慢性病患者': 'warning',
    '过敏体质': 'danger'
  }
  return tagMap[tag] || ''
}
</script>

<style scoped>
.profile-page {
  background-color: #f5f7fa;
  min-height: 100vh;
  padding-bottom: 40px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-header {
  background-color: white;
  padding: 20px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 30px;
}

.page-title {
  font-size: 24px;
  color: #333;
  margin: 0 0 10px;
}

.main-content {
  margin-top: 20px;
}

.user-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  padding: 30px;
  text-align: center;
  margin-bottom: 20px;
}

.user-avatar {
  margin-bottom: 20px;
}

.user-name {
  font-size: 20px;
  color: #333;
  margin: 0 0 5px;
}

.user-role {
  color: #909399;
  margin: 0 0 20px;
}

.user-stats {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.stat-item {
  flex: 1;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: #409EFF;
}

.stat-label {
  font-size: 14px;
  color: #909399;
}

.info-card {
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mt-20 {
  margin-top: 20px;
}

.patient-tags {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

.tag-item {
  margin: 5px;
}

/* 页面过渡动画 */
.page-transition-enter-active,
.page-transition-leave-active {
  transition: all 0.5s ease;
}

.page-transition-enter-from {
  opacity: 0;
  transform: translateY(20px);
}

.page-transition-leave-to {
  opacity: 0;
  transform: translateY(-20px);
}

/* 标签页切换动画 */
.el-tabs__content {
  overflow: hidden;
  position: relative;
}

.el-tab-pane {
  transition: all 0.3s ease-in-out;
}

/* 表单项动画 */
.el-form-item {
  transition: all 0.2s ease-in-out;
}

.el-form-item:hover {
  transform: translateX(5px);
}
</style> 